package com.satan.vote.handler;


import com.satan.vote.vo.ResCode;
import com.satan.vote.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @ClassName GlobalExceptionHandler
 * @Description TODO
 * @date 2022/9/19 23:06
 * @Version 1.0
 */
@Slf4j
@RestControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public ResultVO globalExceptionHandler(Exception e){
        log.error("异常:"+e.getMessage());
        ResCode.GLOBAL_EXCEPTION.setMsg(e.getMessage());
        return ResultVO.fail(ResCode.GLOBAL_EXCEPTION);
    }
}
